package de.bamboit.ordermodule.domain;

import javax.persistence.Entity;
import javax.persistence.GenerationType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;

import de.bamboit.ordermodule.model.BaseObject;

/**
 * @author Andreas Baumgartner
 */
@Entity
public class Product extends BaseObject {

    private Long id;

    private String name;

    private String orderNumber;

    private Double price;

    private Date createdOn;

    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String toString() {
        return orderNumber + ":" + name;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Product)) {
            return false;
        }

        final Product user = (Product) o;

        return !(orderNumber != null ? !orderNumber.equals(user.getOrderNumber()) : user.getOrderNumber() != null);
    }

    public int hashCode() {
        return (orderNumber != null ? orderNumber.hashCode() : 0);        
    }
}
